package com.ztom.daily.n2022.m3;

/**
 * 找出缺失的观测数据
 * <p>
 * https://leetcode-cn.com/problems/find-missing-observations/
 *
 * @author ZhangTao
 */
public class Day27MissingRolls {

    public int[] missingRolls(int[] rolls, int mean, int n) {

        int m = rolls.length;
        int sum = mean * (n + m);
        int missSum = sum;
        for (int roll : rolls) {
            missSum -= roll;
        }
        // 骰子点数范围
        if (missSum < n || missSum > 6 * n) {
            return new int[0];
        }

        int[] res = new int[n];
        int av = missSum / n;
        int mod = missSum % n;
        for (int i = 0; i < n; i++) {
            res[i] = av + (i < mod ? 1 : 0);
        }
        return res;
    }
}
